package com.bw.base.net

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

object RetrofitUtils {

    fun getRetrofit():Retrofit{

        val client=OkHttpClient.Builder()
            .writeTimeout(5,TimeUnit.SECONDS)
            .readTimeout(5,TimeUnit.SECONDS)
            .connectTimeout(5,TimeUnit.SECONDS)
            .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
            .addInterceptor(TokenInterceptor())
            .build()

        return Retrofit.Builder()
            .client(client)
            .baseUrl(Cons.URL_BASE)
            .addConverterFactory(GsonConverterFactory.create())
            .build()

    }

}